Skip to content

code correction and optimization#2

Open
zegabr wants to merge 1 commit into
arijitAD:masterfrom
zegabr:sieve-optimization
Open

code correction and optimization#2
zegabr wants to merge 1 commit into
arijitAD:masterfrom
zegabr:sieve-optimization

Conversation

@zegabr

@zegabr zegabr commented Oct 12, 2019

Copy link
Copy Markdown

For it to work properly, your prime array has to be initialized with all 1s, so I changed it to a vector, which is equivalent and you can fill it initially with 1s as soon as you declare it.

Also, as all multiples of current prime is set to be not prime, the first multiple of the next prime that still isn't set to be not prime is pp, as all pk (for k<p) was set to be not prime in previous iterations.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant